package com.iot08.common.entity.app;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.Date;

/**
 * @author cwj
 * @description
 * @date 2025/3/5 18:30
 **/
@Data
@Document("user_gold_coin")
public class UserGoldCoin implements Serializable {

    @Id
    private String id;

    //当前购买金币的订单信息
    private String orderid;

    //最后购买金币产品的id
    private String gid;

    //是否生效（0：否，1：是）
    private Integer isEffect;

    //用户id
    private String openid;

    //最后购买金币的类型（1：白金套餐，2：黄金套餐，3：红金套餐，4：紫金套餐，5：黑金套餐）
    private Integer type;

    //用户剩余的金币总数
    private Integer goldCoinTotal;

    //当前订单购买的金币数量（当前兑换金币数）
    private Integer currentGoldCoinNum;

    private Date createTime;

    private Date updateTime;

    /*public UserGoldCoin setOrderId(String orderId){
        this.setOrderId(orderId);
        return this;
    }

    public UserGoldCoin setGId(String gId){
        this.setGId(gId);
        return this;
    }*/

    /**
     * @description 构建UserGoldCoin对象
     * @author cwj
     * @param [orderId, gId, type, openId, currentGoldCoinNum, isEffect]
     * @return com.iot08.common.entity.app.UserGoldCoin
     * @date @time 2025/3/6 17:02
     **/
    public UserGoldCoin bulidUserGoldCoin(UserGoldCoin userGoldCoin,String orderId, String gId, Integer type, String openId, Integer currentGoldCoinNum,Integer isEffect) {
        userGoldCoin.setGid(gId);
        userGoldCoin.setType(type);
        userGoldCoin.setOrderid(orderId);
        userGoldCoin.setOpenid(openId);
        userGoldCoin.setCurrentGoldCoinNum(currentGoldCoinNum);
        userGoldCoin.setGoldCoinTotal(currentGoldCoinNum);
        userGoldCoin.setIsEffect(isEffect);
        userGoldCoin.setCreateTime(new Date());
        userGoldCoin.setUpdateTime(new Date());
        return userGoldCoin;
    }
}
